<template>
  <div>
    <el-select v-model="doctor" placeholder="请选择医生">
      <el-option v-for="item in doctors" :key="item.name" :value="item.name">
      </el-option>
    </el-select>
    <div class="block">
      <span class="demonstration">默认</span>
      <el-date-picker v-model="date" type="datetime" placeholder="选择日期时间">
      </el-date-picker>

    </div>
    <el-button type="primary" @click="submit" :disabled="close">提交</el-button>
    <el-button type="primary" @click="next" :disabled="cl" ref="nextstap">下一步</el-button>
  </div>
</template>

<style>
.el-carousel__item h3 {
  color: #2c29cb;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #437ae7;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #437ae7;
}
</style>
<script>
export default {
  data() {
    return {
      doctors: [],
      date: "",
      doctor: "",
      close: false,
      cl:true
    }
  },
  created: function () {
    this.$axios.post("http://localhost:8080/doctor/selecon", {

    }).then(r => {
      console.log(r);
      this.doctors = r.data.data;
    })
    //     this.$axios.post("http://localhost:8080/api/arrangetime", {

    // }).then(r => {
    //   console.log(r);
    //   this.arrangetimes = r.data.data;
    // })
  }, methods: {
    submit() {
      this.$axios.post("http://localhost:8080/doctor/preAppoint", {
        name: this.doctor,
        date: new Date(this.date).toISOString()
      }).then(r => {
        if (r.data.code == "200") {
          localStorage.setItem("doctorid", r.data.data["id"]);
          this.close = true,
          this.cl=false
        } else {
          alert("添加失败，选择的预约时间医生有事")
        }

      },

      )
    },
    next() {

      if (this.$route.path == "/PreDoctor") {
        this.$router.push("/PreMoney");
      
      } 
    }

  }


}
</script>

